﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GFluentCode.Entity
{
    /// <summary>
    /// ORM扩展
    /// </summary>
    public static class GFluentORMTemplate
    {
        /// <summary>
        /// 生成ORM模板
        /// </summary>        
        /// <param name="entityNS">实体实名空间</param>
        /// <param name="ormNS">ORM实名空间</param>
        /// <returns></returns>
        public static string ToORMTemplate(this GFluentTableEntity entity,string entityNS,string ormNS)
        {
            var sb = new StringBuilder();

            sb.AppendLine("using System;")
              .AppendLine("using GFluentCode.ORM;")
              .AppendLine($"using {entityNS};")
              .AppendLine()
              .AppendLine($"namespace  {ormNS}")
              .AppendLine($"{{")
              .AppendLine($"    /// <summary>")
              .AppendLine($"    /// {entity.TableName} ORM")
              .AppendLine($"    /// </summary>")
              .AppendLine($"    public class {entity.TableName}ORM:GFluentORMBase<{entity.TableName}Entity>")
              .AppendLine($"    {{")
              .AppendLine("")
              .AppendLine($"    }}")
              .AppendLine($"}}");

            return sb.ToString();
        }
    }
}
